<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../static/css/css.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../static/js/jquery-2.2.3.min.js"></script>
    <script src="../static/js/jquery-ui.js"></script>
</head>

<body>

<div class="top">
    <div class="logo">
        <img src="../static/img/logo.png" width="371" height="43"/>
    </div>
</div>


<div class="main">
    <div class="nav">
        <a href="/file/"><img src="../static/img/02.png" width="130" height="35"/></a>
        <a href="/report/"><img src="../static/img/03.png" width="130" height="35"/></a>
        <a href="/config/"><img src="../static/img/05.png" width="130" height="35"/></a>
    </div>
    <div class="admin">
        <ul>
            <li class="people">
                <div>
                    <span>员工</span>
                    <input id="wid" name="wid" type="text"/>
                    <label>输入员工姓名自行匹配，例如：张</label>
                </div>
            </li>
            <li class="timeadd">
                <span>时间</span>
                <select id="hour">
                    <option>9</option>
                    <option>10</option>
                </select>
                :
                <select id="minute">
                    <option>30</option>
                    <option>00</option>
                </select>
            </li>
            <li class="admbutt">
                <input id="add" name="add" type="button" value="添加"/>
                <input id="calc" name="calc" type="button" value="重新计算"/>
            </li>
        </ul>

        <ol id="list">
            <!--<li>-->
            <!--<span>张三</span>-->
            <!--<a href="#">删除</a>-->
            <!--</li>-->

        </ol>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>


<div class="foot">
    <div class="foot_main">
        <span>Copyright © 2014 SR All Rights Reserved 湘ICP备14013985号-1</span><span>湖南上容信息技术有限公司  </span>
    </div>
</div>


<script type="text/javascript">
    function delem(obj) {
//        alert("ss")
        $.ajax({
            type: "DELETE",
            url: obj.href,
            dataType: "json",
            success: function (redata) {
                window.location.reload();
            }
        });
        window.location.reload();
    }
    $(function () {
//        加载已设置的弹性考核名单 开始
        $.ajax({ //no need to judge the browser type
            type: "GET", //类型
            url: "../employee/", //请求访问的servlet
            dataType: "json",
            success: function (returnedData) {   //成功返回的回调函数
                var tbody = "";
                $.each(returnedData, function (name, value) {
                    var trs = "";
                    trs += "<li><span>" + name + "</span><a href='../config/" + value + "' onclick='delem(this);return false'> 删除  </a></li>";
                    tbody += trs;
                });
                $("#list").append(tbody);
            }

        });
//        加载已设置的弹性考核名单 开始

//        添加弹性考核人员 开始
        $("#add").click(function () {
            $.ajax({
                type: "UPDATE",
                url: "../config/" + $("#wid").val(),
//                dataType: "json",
                success: function (returnedData) {
                }
            });
            window.location.reload();
        });
//        添加弹性考核人员 结束
//        重新计算开始
        $("#calc").click(function () {
            $.ajax({
                type: "UPDATE",
                url: "../calc/" + $("#hour").val() + "/" + $("#minute").val(),
                success: function (data) {
                    alert(data)
                }
            });
        });
//        重新计算结束

        //模糊搜索匹配 开始
        $("#wid").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "../employees/" + request.term, //根据名称查询
                    dataType: "json",
                    success: function (data) {
                        response($.map(data.ems, function (item) {
                                    return {
                                        label: item.wid//显示工号
                                    }
                                })
                        )
                        ;
                    }
                });
            },
        });
        //模糊搜索匹配 结束


    })//don`t del
</script>
</body>
</html>
